#ifndef MGAME_H
#define MGAME_H

#include <QObject>
#include <set>

#include "mcard.h"

class MGame : public QObject
{
    Q_OBJECT

public:
    enum GameState
    {
        TO_CHOOSE_YOUR_CARD,
        TO_CHOOSE_EVIL,
        TO_CHOOSE_EVIL_CARD,
        TO_CHOOSE_TURN_CARD,
        END
    };
    GameState getState() { return state; }

    enum PlayerID
    {
        PREV = 0,
        YOU = 1,
        NEXT = 2
    };

    // starting
    explicit MGame(QObject *parent = 0);
    QString setYourCards(std::multiset<MCard> cards);
    QString setEvilID(PlayerID id);
    QString setEvilExtraCards(std::multiset<MCard> cards);

    // changing
    QString play(std::multiset<MCard> cards);

    // get data
    int getPlayerMaxRemain(PlayerID id, MCard card);
    int getOutRemain(MCard card);
    int getHandRemain(PlayerID id);
    PlayerID getTurn();

signals:
    void gameOver(bool win);
    
public slots:

private:
    GameState state;

    int EVILID, nowPlayer;
    int OutCardRest[15], MyCardRest[15], HandRest[3];
    MCard EVILCard[3];

    friend class MBoard;
};

#endif // MGAME_H
